package com.example.demo.service.impl;

import com.google.common.base.Charsets;
import com.hazelcast.util.MD5Util;
import com.google.common.hash.Hashing;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static void main(String[] args) {
//        String filename="test";
//
//        //定义一个新的工作簿
//        XSSFWorkbook wb = new XSSFWorkbook();
//        //创建一个Sheet页
//        XSSFSheet sheet = wb.createSheet("Sheet1");
//        XSSFRow row0 = sheet.createRow(0);
//        XSSFCell row01 = row0.createCell(0);
//        row01.setCellValue("苹果");
//        XSSFCell row02 = row0.createCell(1);
//        row02.setCellValue("香蕉");
//
//        XSSFRow row1 = sheet.createRow(1);
//        XSSFCell row11 = row1.createCell(0);
//        row11.setCellValue("计算机");
//        XSSFCell row12 = row1.createCell(1);
//        row12.setCellValue("CPU");
//
//        Date date = new Date();
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
//        // 使用项目根目录, 文件名加上时间戳
//        String path = System.getProperty("user.dir") + "\\" + filename + dateFormat.format(date) + ".xlsx";
//        System.out.println("Excel文件输出路径: " + path);
//        try {
//            File file = new File(path);
//            FileOutputStream fileOutputStream = new FileOutputStream(file);
//            wb.write(fileOutputStream);
//
//            fileOutputStream.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

//       String temp="appId=DQ000001&businessId=10000100&empCode=web951&loginPhone=19809500177&randomStr=2mfd8lWbQSDh5XR6&signType=MD5&apiKey=LKO9iocFsS0b1DtNhxVGvIC6Ugn5pMXy";
//       String sign= MD5Util.toMD5String(temp).toUpperCase();
//        System.out.println(sign);
        //153CF89B5AF6326C47F55D7C7E291E7E
        //FFC2641355038787715B82D1D972CD92

        String tempStr="ppId=DQ000001&busin";
        String result1=Hashing.md5().newHasher().putString(tempStr, Charsets.UTF_8).hash().toString();
        System.out.println(result1);
    }
}

